﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Components
{
    public partial class ChangeCase : UserControl
    {
        public ChangeCase()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = textBox1.Text;
            string newstr = Change(str);
            textBox1.Text = newstr;
        }

        public string Change(string s)
        {
            char[] arr = s.ToCharArray();
            s = s.ToLower();
            char[] arrLow = s.ToCharArray();

            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] == arrLow[i])
                    arr[i] = char.ToUpper(arr[i]);
                else
                    arr[i] = char.ToLower(arr[i]);

            }

            return new string(arr);
        }
    }
}
